package com.example.st.controller;

import com.example.st.common.ResponseResult;
import com.example.st.entity.Bp;
import com.example.st.service.AmapService;
import com.example.st.service.BpService;
import com.example.st.service.GptService;
import com.example.st.service.PushService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/gpt")
public class GPTController {
    @Autowired
    private PushService pushService;

    @Autowired
    private AmapService amapService;

    @Autowired
    private GptService gptService;
    @GetMapping("/test")
    public ResponseResult test(@RequestParam("uid") String uid, @RequestParam("text") String text) {
        if (StringUtils.isEmpty(uid) || StringUtils.isEmpty(text)) {
            log.error("uid或text不能为空");
            return new ResponseResult<>(-1, "uid或text不能为空", null);
        }
        return pushService.pushMessageToXFServer(uid, text);
    }

    @GetMapping("/test2")
    public ResponseResult test2(@RequestParam("origin") String origin, @RequestParam("destination") String destination ){
        if (StringUtils.isEmpty(origin) || StringUtils.isEmpty(destination)) {
            log.error("origin或destination不能为空");
            return new ResponseResult<>(-1, "origin或destination不能为空", null);
        }
        Map<String, Object> routeInfo = amapService.getRouteInfo(origin, destination);
        return new ResponseResult<>(0, "成功", routeInfo);
    }

    @GetMapping("/recommendPath")
    public ResponseResult test3(@RequestParam("uid") String uid, @RequestParam("text") String text, @RequestParam("origin") String origin, @RequestParam("destination") String destination ){
        return gptService.recommendPath(uid, text, origin, destination);
    }

    @GetMapping("/recommendDestination")
    public ResponseResult test4(@RequestParam("uid") String uid, @RequestParam("text") String text){
        return gptService.recommendDestination(uid, text);
    }
}
